document.getElementById("result").innerHTML = localStorage.getItem("payVipOrderId");
var result = document.getElementById("result");

console.log(result.innerHTML)

var userIdmessage = document.getElementById("userIdmessage");
axios({
    url: "/findOrderInnerJoinUser",
    method: "get",
    params: {
        payVipOrderId: result.innerHTML,
    }
})
    .then(function (data) {
        console.log(data.data.data.object)
        var payNo = document.getElementById("payNo");
        payNo.innerHTML = data.data.data.object.payNo/*订单号 */
        var userName = document.getElementById("userName");
        userName.innerHTML = data.data.data.object.userName/*订单人 */
        var payTime = document.getElementById("payTime");
        payTime.innerHTML = data.data.data.object.payTime/*支付时间 */
        var nowPrice = document.getElementById("nowPrice");
        nowPrice.innerHTML = "￥"+data.data.data.object.nowPrice+"元"/*支付金额 */
        var introduction = document.getElementById("introduction");
        introduction.innerHTML = data.data.data.object.introduction/*商品介绍 */

        var goodsName = document.getElementById("goodsName");
        goodsName.innerHTML = data.data.data.object.goodsName/*商品名称 */
        // var userId = document.getElementById("userId");
        // userId.innerHTML = data.data.data.object.userId/*用户id */
        var payVipOrderId = document.getElementById("payVipOrderId");
        payVipOrderId.innerHTML = data.data.data.object.payVipOrderId/*vipid */


        /*之后修改用户的vip状态！！！ */
        axios({
            url: "/updateUserVip",
            method: "put",
            params: {
                userId: userIdmessage.innerHTML,
            }
        })
            .then(function (data) {
               
                console.log("修改用户的vip状态成功！！！")

            })
            .catch(function (error) {
                console.log(error)
            })



            /*将用户购买是否支付改成已支付 */
        axios({
            url: "/updateOfVip",
            method: "get",
            params: {
                payVipOrderId: payVipOrderId.innerHTML,
            }
        })
            .then(function (data) {
                console.log(data)
                console.log("修改是否支付成功")
            })
            .catch(function (error) {
                console.log(error)
            })
            /*修改订单支付时间 */
        
        axios({
            url: "/updatePayTime",
            method: "put",
            params: {
                payVipOrderId: payVipOrderId.innerHTML,
            }
        })
            .then(function (data) {
                console.log("修改订单支付时间成功")
            })
            .catch(function (error) {
                console.log(error)
            })
        /*修改用户vip时间 */


        axios({
            url: '/judgeUserVipTime',
            method: 'post',
            params: {
                userId: userIdmessage.innerHTML,
            }
        })
            .then(function (data) {
                console.log(data)
            })
            .catch(function (error) {
                console.log('判断是否充值vip以及vip时间操作失败')
            })


        axios({
            url: "/updateUserVipTime",
            method: "put",
            params: {
                orderId: payVipOrderId.innerHTML,
                userId: userIdmessage.innerHTML,
            }
        })
            .then(function (data) {
               
                console.log(data)

            })
            .catch(function (error) {
                console.log("error")
            })



    })
    .catch(function (error) {
        console.log(error)
    })





    /*退出登录！！！！ */
var gooutbtn = document.getElementById("gooutbtn");
gooutbtn.onclick = function(){
    axios({
        url: '/logout',
        method: 'post',
    })
        .then(function (data) {
            
            console.log("退出账号成功！！！")
            window.location.href = "/index"
        })
        .catch(function (error) {
            
            console.log('失败')
        })
}